__author__ = 'l4537'
#coding:utf-8
import time,os,re,sys
def Re(res,total,id = "1"):
    #1.普通模式正则，2，多行模式正则
    if id == "1":
        data = re.findall(str(res),total)
    if id == "2":
        data = re.findall(str(res),total,re.S)
    return data
class CISCOMDS:
    def __init__(self,data):
        self.data = data
    def mds_port(self):
        pass
        data = Re("fc(\d+)\/(\d+)\s+(\S+)\s+FX\s+\S+\s+(\S+)",self.data,"2")
        #[('1', '1', '1', 'up'), ('1', '2', '1', 'up'), ('1', '3', '1', 'up'),
        return data
    def mds_wwn(self):
        pass
        data = Re("fc(\d+)\/(\d+)\s+(\S+)\s+\S{8}\s+(..:..:..:..:..:..:..:..)", self.data, "2")
        #[('1', '1', '1', '20:04:00:c0:dd:32:25:82'), ('1', '1', '1', '10:00:e0:97:96:11:b1:10'), ('
        return data
    #改动信息如下：('1', '1', '13886304', '22694144', '0', '0', ' Wed Sep 16 12:49:31 2015')
    def mds_portmess(self):
        #[(('1', '1', '13886304', '22694144', '0', '0', ' Wed Sep 16 12:49:31 2015'),
        data = Re("fc(\d+)\/(\d+) is up.*?(\S+)\s+discards,\s+(\S+).*?Interface last changed at(\s+\w+\s+\w+\s+\d+\s+\S+\s+\d+)*", self.data, "2")
        return data
    def mds_right(self):
        data = Re("fc(\d+)\/(\d+)\s+sfp\s+is\s+present.*?Tx Power\s+:\s+(\S+).*?Rx Power\s+:\s+(\S+)", self.data, "2")
        return data
    def juhe(self):
        mds_port = self.mds_port()
        mds_wwn = self.mds_wwn()
        mds_portmess = self.mds_portmess()
        mds_right = self.mds_right()
        ciscodata = {}
#         for i in mds_port:
#             ciscodata
    def mds_sulv(self):
        data = Re("fc(\d+)/(\d+)\s+(\d+)\s+\d+\s+(\d+)", self.data, "2")
        return data
a = open("11.txt","r")
b= a.read()
#
a = CISCOMDS(b)
for i in a.mds_sulv():
    print(i)